<html><head><title>Keyboard.pb</title></head>
<body bgcolor="#EFF1F0" link="#3A3966" vlink="#000000" alink="#000000">
<pre><font face="Courier New, Courier, mono"size="2"><font color="#3A3966">;
</font><font color="#3A3966">; ------------------------------------------------------------
</font><font color="#3A3966">;
</font><font color="#3A3966">;   PureBasic - Keyboard example file
</font><font color="#3A3966">;
</font><font color="#3A3966">;    (c) Fantaisie Software
</font><font color="#3A3966">;
</font><font color="#3A3966">; ------------------------------------------------------------
</font><font color="#3A3966">;
</font>
<b><font color="#3A3966">If</font></b> <font color="#3A3966">InitKeyboard</font>() = 0 <b><font color="#3A3966">Or</font></b> <font color="#3A3966">InitSprite</font>() = 0
<font color="#3A3966">  MessageRequester</font>(&quot;Error&quot;, &quot;Can't initialize the sprite system.&quot;, 0)
  <b><font color="#3A3966">End</font></b>
<b><font color="#3A3966">EndIf</font></b>

<font color="#3A3966">MessageRequester</font>(&quot;Information&quot;, &quot;This will test the fast keyboard access...&quot;+<font color="#924B72">#LF$</font>+&quot;Press 'ESC' to quit!&quot;, 0)


<b><font color="#3A3966">If</font></b> <font color="#3A3966">OpenScreen</font>(800, 600, 32, &quot;Keyboard&quot;)

  x = 100
  y = 100
  
<font color="#3A3966">  LoadSprite</font>(0, <font color="#924B72">#PB_Compiler_Home</font> + &quot;examples/sources/Data/PureBasic.bmp&quot;)

  <b><font color="#3A3966">Repeat</font></b>
  
<font color="#3A3966">    FlipBuffers</font>()
    
<font color="#3A3966">    ClearScreen</font>(<font color="#3A3966">RGB</font>(0,0,0))
  
<font color="#3A3966">    ExamineKeyboard</font>()
    
    <b><font color="#3A3966">If</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Left</font>)
      x-1
    <b><font color="#3A3966">EndIf</font></b>
  
    <b><font color="#3A3966">If</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Right</font>)
      x+1
    <b><font color="#3A3966">EndIf</font></b>
  
    <b><font color="#3A3966">If</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Up</font>)
      y-1
    <b><font color="#3A3966">EndIf</font></b>
  
    <b><font color="#3A3966">If</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Down</font>)
      y+1
    <b><font color="#3A3966">EndIf</font></b>
    
    <b><font color="#3A3966">For</font></b> OffsetY=0 <b><font color="#3A3966">To</font></b> 600 <b><font color="#3A3966">Step</font></b> 70
      <b><font color="#3A3966">For</font></b> OffsetX=0 <b><font color="#3A3966">To</font></b> 800 <b><font color="#3A3966">Step</font></b> 200
<font color="#3A3966">        DisplaySprite</font>(0, OffsetX+x, y+OffsetY)
      <b><font color="#3A3966">Next</font></b>
      
      <b><font color="#3A3966">For</font></b> OffsetX=0 <b><font color="#3A3966">To</font></b> 800 <b><font color="#3A3966">Step</font></b> 200
<font color="#3A3966">        DisplaySprite</font>(0, OffsetX+x+90, y+OffsetY+35)
      <b><font color="#3A3966">Next</font></b>
    <b><font color="#3A3966">Next</font></b>
    
  <b><font color="#3A3966">Until</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Escape</font>)

<b><font color="#3A3966">Else</font></b>
<font color="#3A3966">  MessageRequester</font>(&quot;Error&quot;, &quot;Impossible to open a 800*600 32 bit screen&quot;,0)
<b><font color="#3A3966">EndIf</font></b>

<b><font color="#3A3966">End</font></b>   </font></pre>
</body></html>
